package com.xzy.urp.controller;


import com.xzy.urp.common.result.R;
import com.xzy.urp.pojo.query.CourseTimeQuery;
import com.xzy.urp.pojo.vo.BaseInfoVO;
import com.xzy.urp.pojo.vo.CourseTimeVO;
import com.xzy.urp.service.BaseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xzy
 * @since 2022-02-17
 */
@RestController
@RequestMapping("/admin/baseInfo")
@Api(tags = "教室信息相关接口")
public class BaseInfoController {
//教室课表查询
// 可用教室查询

    BaseInfoService baseInfoService;

    public BaseInfoController(BaseInfoService baseInfoService) {
        this.baseInfoService = baseInfoService;
    }

    @ApiOperation("教室课表")
    @PostMapping("get/TimeTable")
    public R baseTimeTable(@ApiParam("") @RequestBody Integer baseId) {
        List<CourseTimeVO> timeByBaseId = baseInfoService.getTimeByBaseId(baseId);

        return R.ok().message("获取成功").data("timeByBaseId",timeByBaseId);
    }
    @ApiOperation("某时段可用教室查询")
    @PostMapping("list/Addable")
    public R selectedCourse(@ApiParam("结束周期") @RequestBody CourseTimeQuery query) {
        List<BaseInfoVO> addableBase = baseInfoService.
                getAddableBase(query.getSemester(), query.getSection(), query.getStartWeeks(), query.getEndWeeks());
        return R.ok().message("获取成功").data("addableBase",addableBase);
    }
    @ApiOperation("某教学楼所有教室列表")
    @PostMapping("list/ByBuild")
    public R baseList4build(@ApiParam("") @RequestBody String build) {
        List<BaseInfoVO> baseInfoByBuild = baseInfoService.getBaseInfoByBuild(build);
        return R.ok().message("获取成功").data("baseInfoByBuild",baseInfoByBuild);
    }
    @ApiOperation("所有教室列表")
    @PostMapping("list/All")
    public R baseList() {
        List<BaseInfoVO> baseInfoVOS = baseInfoService.listAll();
        return R.ok().message("获取成功").data("baseInfoVOS",baseInfoVOS);
    }
}

